//
//  StatusCellBottomView.swift
//  weibo19
//
//  Created by Arvin on 15/11/14.
//  Copyright © 2015年 Arvin. All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {

    // MARK: 按钮点击
    // 一定要加@objc
    @objc private func didClickRetweetedBtn() {
        let vc = TempViewController()
        retweeter.NavigitionController()?.pushViewController(vc, animated: true)
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private let width = 0.5
    private let scale = 0.6
    func setupUI() {
        backgroundColor = UIColor(patternImage: UIImage(named: "timeline_card_bottom_background")!)
        addSubview(retweeter)
        addSubview(comment)
        addSubview(like)
        addSubview(sepLine1)
        addSubview(sepLine2)
        
        retweeter.addTarget(self, action: "didClickRetweetedBtn", forControlEvents: UIControlEvents.TouchUpInside)
        
        retweeter.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(snp_top)
            make.bottom.equalTo(snp_bottom)
            make.left.equalTo(snp_left)
        }
        
        comment.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(snp_top)
            make.bottom.equalTo(snp_bottom)
            make.left.equalTo(retweeter.snp_right)
            make.width.equalTo(retweeter.snp_width)
        }
        
        like.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(snp_top)
            make.bottom.equalTo(snp_bottom)
            make.left.equalTo(comment.snp_right)
            make.right.equalTo(snp_right)
            make.width.equalTo(comment.snp_width)
        }
        
        sepLine1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweeter.snp_right)
            make.centerY.equalTo(snp_centerY)
            make.width.equalTo(width)
            make.height.equalTo(snp_height).multipliedBy(scale)
        }
        
        sepLine2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(comment.snp_right)
            make.centerY.equalTo(snp_centerY)
            make.width.equalTo(width)
            make.height.equalTo(snp_height).multipliedBy(scale)
        }

    }

    private lazy var retweeter: UIButton = {
        let ret = UIButton()
        ret.setImage(UIImage(named: "timeline_icon_retweet"), forState: UIControlState.Normal)
        ret.setTitle("转发", forState: .Normal)
        ret.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        ret.titleLabel?.font = UIFont.systemFontOfSize(14.0)
        return ret
    }()
    private lazy var comment: UIButton = {
        let ret = UIButton()
        ret.setImage(UIImage(named: "timeline_icon_comment"), forState: UIControlState.Normal)
        ret.setTitle("评论", forState: .Normal)
        ret.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        ret.titleLabel?.font = UIFont.systemFontOfSize(14.0)
        return ret
        }()
    private lazy var like: UIButton = {
        let ret = UIButton()
        ret.setImage(UIImage(named: "timeline_icon_unlike"), forState: UIControlState.Normal)
        ret.setTitle("赞", forState: .Normal)
        ret.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        ret.titleLabel?.font = UIFont.systemFontOfSize(14.0)
        return ret
        }()
    
    private lazy var sepLine1: UIView = {
        let sep = UIView()
        sep.backgroundColor = UIColor(patternImage: UIImage(named: "timeline_card_bottom_line_highlighted")!)
        return sep
    }()
    
    private lazy var sepLine2: UIView = {
        let sep = UIView()
        sep.backgroundColor = UIColor(patternImage: UIImage(named: "timeline_card_bottom_line_highlighted")!)
        return sep
        }()

}
